package exception;

import java.io.*;

//异常处理在io中的应用
public class FinallyDemo2 {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("a/b/c/fos.txt");
            fos.write(1);
        } catch (IOException e) {
            System.out.println("出现io异常并解决了");
        } finally {
            try {
                if (fos != null) {
                    fos.close();
                }
            } catch (Exception e) {
                System.out.println("关闭流时出现异常并解决了");
            }
        }
        System.out.println("程序结束了");
    }
}
